﻿
// **************************************************************************
//    Class Created by Mick Doherty (Dotnetrix) Feb 2010
//    http://dotnetrix.co.uk/
//
//    ...for GlassUI (an AeroGlass UI Library)
//    http://glassui.codeplex.com/
// **************************************************************************

using System;
using System.Runtime.InteropServices;

namespace GlassUI
{
    internal sealed partial class NativeMethods
    {
        private NativeMethods() { }

        internal sealed class DWMAPI
        {
            private DWMAPI() { }

            #region Method Imports

            [DllImport("dwmapi.dll", SetLastError = true)]
            public static extern IntPtr DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);

            [DllImport("dwmapi.dll", SetLastError = true)]
            public static extern IntPtr DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);

            [DllImport("dwmapi.dll", SetLastError = true)]
            public static extern IntPtr DwmIsCompositionEnabled([MarshalAs(UnmanagedType.Bool)]out bool pfEnabled);

            [DllImport("dwmapi.dll", SetLastError = true)]
            public static extern IntPtr DwmGetColorizationColor(out int pcrColorization, [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend);

            //[DllImport("dwmapi.dll")]
            //[return: MarshalAs(UnmanagedType.Bool)]
            //public static extern bool DwmDefWindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, out IntPtr plResult);

            #endregion

            #region Structures

            [StructLayout(LayoutKind.Sequential)]
            public struct MARGINS
            {
                public int cxLeftWidth;
                public int cxRightWidth;
                public int cyTopHeight;
                public int cyBottomHeight;
                public MARGINS(int leftWidth, int rightWidth, int topHeight, int bottomHeight)
                {
                    cxLeftWidth = leftWidth;
                    cxRightWidth = rightWidth;
                    cyTopHeight = topHeight;
                    cyBottomHeight = bottomHeight;
                }
            }

            [StructLayout(LayoutKind.Sequential)]
            public struct DWM_BLURBEHIND
            {
                public DwmBlurBehindFlags dwFlags;
                public bool fEnable;
                public IntPtr hRgnBlur;
                public bool fTransitionOnMaximized;
            }

            #endregion

            #region Enumerations

            [Flags()]
            public enum DwmBlurBehindFlags : uint
            {
                DWM_BB_ENABLE = 0x1,
                DWM_BB_BLURREGION = 0x2,
                DWM_BB_TRANSITIONONMAXIMIZED = 0x4
            }

            #endregion
        }
    }
}
